|
Pipelines againIn this exercise, we write points and pipes of a diagram in the same format used earlier for reading. Step 1Use relativeResource :: Resource -> String -> <ReadGraph> Resource (Simantics/DB) Converts a relative URI to a resource starting from the given resource and currentModel :: <ReadGraph> Resource (Simantics/DB) Gives the current active model. to define a variable Print the value to the console and check that it corresponds to the resource id given by the graph debugger. Step 2Import the ontology Use (#) :: Resource -> Resource -> <ReadGraph> [Resource] (Simantics/DB)
and map :: FunctorE a => (b -> <d> c) -> a b -> <d> a c (Prelude) Applies the function to all elements of the container and returns the similarly shaped container with the results: For lists,
for example
nameOf :: Browsable a => a -> <ReadGraph> String (Simantics/DB) Reads the name of the value. Step 3Import the ontology Modify the commands in step 2 to find only the points ( Step 4Print the names and elevations of all points in and the attribute Step 5Use the relation singleObject :: Resource -> Resource -> <ReadGraph> Resource (Simantics/DB) Assumes that there is exactly one object with the given subject and predicate and returns it. to find the graphical symbol of the point. Use the relation to read the transformation of the point. The last two elements of the transformation are the coordinates of the point. Step 6Give an indices for all points you find for example using range :: Integer -> Integer -> [Integer] (Prelude)
zip :: [a] -> [b] -> [(a, b)] (Prelude) Combines two lists into one list of pairs. The length of the resulting list is the length of the smallest input list.
Step 7Print the data about the points in the format described in the previous pipelines exercise. Step 8Print the corresponding data about the pipes. |